package com.doyens.common.config.handler;

import com.doyens.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//aop通知类
@ControllerAdvice
public class GlobalExceptionHandler {
    //具体的异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
    @ExceptionHandler(NullPointerException.class)
    public Result error1(NullPointerException e){
        e.printStackTrace();
        return Result.fail().message("空指针异常");
    }
}
